{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "file_global = './CuraEngine/test3_global_e0'  #  layer_height 0.05  layer_height_0 0.1\n",
    "file_extruder = \"./CuraEngine/test3_extrude_e0\"\n",
    "\n",
    "cura_global = \"./Cura/cura_fine_global_2\"\n",
    "cura_extrude = \"./Cura/cura_fine_extrude_2\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(cura_global,'r') as f:\n",
    "   global_lines = f.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "global_setting = []\n",
    "global_setting_split = []\n",
    "global_setting =  global_lines.split(\"-s\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "for i,sets in enumerate(global_setting):\n",
    "    temps = sets.split(\"=\")\n",
    "    temps = [temp.strip()  for temp in temps]\n",
    "    global_setting_split.append(temps)\n",
    "    # print(\"-->\",sets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import csv\n",
    "f = open(\"./Cura/c_global_setting_2.csv\",'w')\n",
    "f_csv = csv.writer(f)\n",
    "\n",
    "for temp in global_setting_split:\n",
    "    f_csv.writerow(temp)\n",
    "f.close()"
   ]
  },
  {
   "source": [
    "###  下面开始进行挤出机设置的读取"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(cura_extrude,'r') as f:\n",
    "   extruder_lines = f.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "extruder_setting = extruder_lines.split(\"-s\")\n",
    "extruder_setting_split = []\n",
    "for i,sets in enumerate(extruder_setting):\n",
    "    temps = sets.split(\"=\")\n",
    "    temps = [temp.strip()  for temp in temps]\n",
    "    extruder_setting_split.append(temps)\n",
    "    # print(\"-->\",sets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "f = open(\"./Cura/c_extruder_setting_2.csv\",'w')\n",
    "f_csv = csv.writer(f)\n",
    "\n",
    "for temp in extruder_setting_split:\n",
    "    f_csv.writerow(temp)\n",
    "f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.11-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python361164bitpytrochcondae51393cc87754f83a49faf18fa04379a",
   "display_name": "Python 3.6.11 64-bit ('pytroch': conda)"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}